﻿using System;
using System.Collections.Generic;
using Autodesk.Revit.DB;
using YJKArchUtils.Utils;

namespace YJKCarSlopingPath.Utils
{
	public struct ThreeLine
	{
		public int RefObjectIndex
		{
			get
			{
				return this.m_RefObjectIndex;
			}
		}

		public EdgeInfo CenterLine
		{
			get
			{
				return this.m_CenterLine;
			}
		}

		public EdgeInfo LeftLine
		{
			get
			{
				return this.m_LeftLine;
			}
			set
			{
				this.m_LeftLine = value;
			}
		}

		public EdgeInfo RightLine
		{
			get
			{
				return this.m_RightLine;
			}
			set
			{
				this.m_RightLine = value;
			}
		}

		public EdgeInfo GetReverseCenterLine()
		{
			return this.ReverseCurve(this.m_CenterLine);
		}

		public EdgeInfo GetReverseLeftLine()
		{
			return this.ReverseCurve(this.m_LeftLine);
		}

		public EdgeInfo GetReverseRightLine()
		{
			return this.ReverseCurve(this.m_RightLine);
		}

		public List<EdgeInfo> GetLoop()
		{
			List<EdgeInfo> list = new List<EdgeInfo>();
			XYZ startPoint = this.m_LeftLine.StartPoint;
			XYZ startPoint2 = this.m_RightLine.StartPoint;
			XYZ endPoint = this.m_RightLine.EndPoint;
			XYZ endPoint2 = this.m_LeftLine.EndPoint;
			EdgeInfo item = new EdgeInfo(startPoint, startPoint2, 0.0);
			list.Add(item);
			list.Add(this.m_RightLine);
			EdgeInfo item2 = new EdgeInfo(endPoint, endPoint2, 0.0);
			list.Add(item2);
			list.Add(this.ReverseCurve(this.m_LeftLine));
			return list;
		}

		public double LeftWidth()
		{
			if (this.m_CenterLine.IsArc)
			{
				double radius = this.m_CenterLine.Radius;
				double radius2 = this.m_LeftLine.Radius;
				return Math.Abs(radius - radius2);
			}
			XYZ startPoint = this.m_CenterLine.StartPoint;
			XYZ endPoint = this.m_CenterLine.EndPoint;
			XYZ startPoint2 = this.m_LeftLine.StartPoint;
			return Geometry.CalculateFootPoint(startPoint, endPoint, startPoint2).DistanceTo(startPoint2);
		}

		public double RightWidth()
		{
			if (this.m_CenterLine.IsArc)
			{
				double radius = this.m_CenterLine.Radius;
				double radius2 = this.m_RightLine.Radius;
				return Math.Abs(radius - radius2);
			}
			XYZ startPoint = this.m_CenterLine.StartPoint;
			XYZ endPoint = this.m_CenterLine.EndPoint;
			XYZ startPoint2 = this.m_RightLine.StartPoint;
			return Geometry.CalculateFootPoint(startPoint, endPoint, startPoint2).DistanceTo(startPoint2);
		}

		public ThreeLine(ThreeLine rhs)
		{
			this.m_RefObjectIndex = rhs.m_RefObjectIndex;
			this.m_CenterLine = rhs.CenterLine;
			this.m_LeftLine = rhs.LeftLine;
			this.m_RightLine = rhs.RightLine;
		}

		public ThreeLine(int refObjectIndex, EdgeInfo centerLine, EdgeInfo leftLine, EdgeInfo rightLine)
		{
			this.m_RefObjectIndex = refObjectIndex;
			this.m_CenterLine = centerLine;
			this.m_LeftLine = leftLine;
			this.m_RightLine = rightLine;
		}

		private EdgeInfo ReverseCurve(EdgeInfo curve)
		{
			return new EdgeInfo(curve.EndPoint, curve.StartPoint, -curve.Bulge);
		}

		private int m_RefObjectIndex;

		private EdgeInfo m_CenterLine;

		private EdgeInfo m_LeftLine;

		private EdgeInfo m_RightLine;
	}
}
